import "./css/common.less";
import "mint-ui/lib/style.css";
import "./css/discovery.less";
import "./css/my.less";
import "./css/components.less";
import "./css/animation.less";
import "./css/searchBlock.less";
import Vue from "vue";
import MintUI from "mint-ui";
import App from "./view/app.vue";
import vueRouter from "vue-router";
import VueBus from "./js/vue-bus";
import {Indicator} from 'mint-ui';
import { Popup } from 'mint-ui';
import { IndexList, IndexSection } from 'mint-ui';
Vue.component(IndexList.name, IndexList);
Vue.component(IndexSection.name, IndexSection);
Vue.component(Popup.name, Popup);
Vue.use(VueBus);
Vue.use(MintUI);
Vue.use(vueRouter);
const Routers = [
    {
        path:'*',
        redirect:'/discovery'
    },
    {
        path:'/discovery',
        component:(resolve) => require(['./view/discovery.vue'],resolve)
    },
    {
        path:'/podcast',
        component:(resolve) => require(['./view/podcast.vue'],resolve)
    },
    {
        path:'/my',
        component:(resolve) => require(['./view/my.vue'],resolve)
    },
    {
        path:'/focus',
        component:(resolve) => require(['./view/focus.vue'],resolve)
    },
    {
        path:'/village',
        component:(resolve) => require(['./view/village.vue'],resolve)
    },
    {
        path:'/occurerror',
        component:(resolve) => require(['./view/occurerror.vue'],resolve)
    }
]
const routerConfig = {
    mode:'history',
    routes:Routers
}
const router = new vueRouter(routerConfig);
let vm = new Vue({
    el:"#app",
    methods:{
        getData(theData){
            let api = "https://autumnfish.cn/" + theData.url;
            return new Promise(resolve=>{
                resolve(
                    Indicator.open({
                        text:"加载中...",
                        spinnerType:"double-bounce"
                    })
                )
            }).then(value=>{
                return new Promise(resolve=>{
                    resolve(Vue.axios.get(api))
                })
            }).then(
                response=>{
                    theData.data = response.data;
                },
                reason=>{
                    this.$router.push('/occurerror').catch((err)=>err);
                }
            ).finally(()=>{
                Indicator.close();
            })
        }
    },
    router:router,
    render:h=>h(App)
})
export {vm}